package cn.alusiaor.springbootaop.exception;


import cn.alusiaor.springbootaop.exception.enums.BaseExceptionEnum;

/**
 * @author zhuzhiping
 * @date 2019/11/27
 * @description 功能描述
 */
public class MyException extends RuntimeException {
    private Integer code;
    private String  msg;

    public MyException(String msg) {
        this.code = -1;
        this.msg = msg;
    }

    public MyException(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public MyException(BaseExceptionEnum baseExceptionEnum) {
        this.code = baseExceptionEnum.getCode();
        this.msg = baseExceptionEnum.getMessage();
    }

    public MyException(String message, Integer code, String msg) {
        super(message);
        this.code = code;
        this.msg = msg;
    }

    public MyException(String message, Throwable cause, Integer code, String msg) {
        super(message, cause);
        this.code = code;
        this.msg = msg;
    }

    public MyException(Throwable cause, Integer code, String msg) {
        super(cause);
        this.code = code;
        this.msg = msg;
    }

    public MyException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace, Integer code, String msg) {
        super(message, cause, enableSuppression, writableStackTrace);
        this.code = code;
        this.msg = msg;
    }


    @Override
    public String toString() {
        return "MyException{" +
                "code=" + code +
                ", msg='" + msg + '\'' +
                '}';
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }
}
